<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<script>
    flag=true;
    function onSubmit() {
        if(flag){
            var user=document.getElementById("username").value,
                psw=document.getElementById("password").value;
            for(var i=0;i<localStorage.length;i++){
                var getKey=localStorage.key(i);
                if(getKey.substring(0,6)=="userID"){
                    var str=localStorage.getItem(getKey);
                    var data=JSON.parse(str);
                    if(user==data.user&&psw==data.password) {
                        alert("登录成功！");
                       // window.open("info.html");
                        var result="欢迎用户:"+data.user+"\n"+"邮箱:"+data.mail;
                        p='<html><head><title>欢迎</title> <link rel="stylesheet" type="text/css" href="css/style.css" /></head><body><div1>'+result+'</div1></body></html>';
                        w=window.open('about:blank');
                        w.document.write(p);
                        w.document.close();
                        return;
                    }
                }
            }
            alert("用户名或密码不正确！");
            return;
        }
        else
        alert("用户名或密码不正确！");
    }



</script>
<body>
<div1>
<form>
    用户名：<br>
    <input type="text" name="username" id="username">
    <br>
    密码：<br>
    <input type="password" name="password" id="password">
    <br><br>
    <input type="submit" value="登录" onclick="onSubmit()">
</form>
   <p> <a href="register.html">没有账号？点击注册</a> </p>
</div1>
</body>
</html>